package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ConvertsAListSeparatedWithASpaceToArray {
	public static String[] parseArray(String line) {
		String[] retStrings = new String[0];
		String nLine = "";
		for (int i = 0; i < line.length(); i++) {
			if (Character.toString(line.charAt(i)).equals(" ")) {
				retStrings = addToList(nLine, retStrings);
				nLine = "";
			} else {
				nLine = nLine.concat(Character.toString(line.charAt(i)));
			}
		}
		return retStrings;
	}

	public static String[] addToList(String object, String[] array) {
		String[] ret = new String[array.length + 1];
		for (int i = 0; i < array.length; i++) {
			ret[i] = array[i];
		}
		ret[array.length] = object;
		return ret;
	}
}
